package tests;

/**
 * @author 李夏
 * @version 1.0
 */

import common.Utils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.IOException;
import java.lang.reflect.Method;
import java.time.Duration;

/**
 * 退出功能测试
 */
public class ExitPage extends Utils {
    public static String url = "http://127.0.0.1:58080/sign-in.html";
    public ExitPage() {
        super(url);
    }


    public void  exitSuc() throws InterruptedException, IOException {
        LoginPage loginPage=new LoginPage();
        loginPage.loginSuc();
        WebDriverWait wait=new WebDriverWait(driver, Duration.ofSeconds(10));
        WebElement searchBox=wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#index_nav_nickname")));
        searchBox.click();
        wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#index_user_logout > span"))).click();
        driver.findElement(By.cssSelector("body > div > div > div > div:nth-child(1) > div > div.card.card-md > div > h2"));
        Method method = new Object() {
        }.getClass().getEnclosingMethod();
        String methodName = method.getName();
        getScreenShot(getClass().getName(),methodName);
    }
}
